home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / WORLDSRC.ZIP / DEMONS.C < prev    next >
C/C++ Source or Header  |  1992-08-13  |  10KB  |  443 lines

  1. #define EXTERN extern
  2.  
  3. #include "parame.inc"
  4. #include "variab.h"
  5. #include "arrays.h"
  6.  
  7. /* World C Version 1.00 copyright 1987 J.D.McDonald 
  8.    Use as you like for non-commercial purposes, but please
  9.    leave this note, and document any changes you make as yours */
  10.  
  11. mdemon()
  12. {
  13.  
  14.     int             qtim, z, i, kkwr;
  15.     /*
  16.      * subroutine to care for comings and goings of martians 
  17.      */
  18.  
  19.     qtim = (turns % 100) < 75;
  20.     /*
  21.      * the player must have entered mars once in the day and once at night,
  22.      * and then wait 4 turns before they come close 
  23.      */
  24.  
  25.     if (martim < 7) {
  26.     if (loc == 27 || loc == 50 || loc == 41) {
  27.         oldloc = 0;
  28.         speak(152);
  29.     }
  30.     if (loc >= 26 && loc <= 50) {
  31.         if (qtim && (martim == 0 || martim == 2))
  32.         martim |= 1;
  33.         if (!qtim && (martim == 0 || martim == 1))
  34.         martim |= 2;
  35.         if (martim >= 3)
  36.         martim += 1;
  37.     }
  38.     }
  39.     if (qtim)
  40.     return;
  41.     /*
  42.      * they will appear at once if he falls in their hockey rink 
  43.      */
  44.  
  45.     if (loc == 38 && !marflg[5]) {
  46.     marflg[5] = 1;
  47.     martim = 7;
  48.     speak(169);
  49.     return;
  50.     }
  51.     for (i = 0; i < 5; i++)
  52.     marflg[i] = 0;
  53.     z = (turns % 100);
  54.     /* wont come close if martim < 7 */
  55.  
  56.     if (martim < 7) {
  57.     if (loc != 51)
  58.         speak(141);
  59.     goto lab60;
  60.     }
  61.     if (z > 75 && z < 99)
  62.     marflg[4] = 1;
  63.     if (z > 76 && z < 98)
  64.     marflg[0] = 1;
  65.     if (z > 78 && z < 95)
  66.     marflg[3] = 1;
  67.     if (z > 78 && z < 96)
  68.     marflg[2] = 1;
  69.     if (z > 77 && z < 97 && obloc[HPUCK] == 38)
  70.     marflg[1] = 1;
  71.     /* announce the goings on of the martians */
  72.  
  73.     if (marflg[5] && z == 75 && loc != 38)
  74.     speak(154);
  75.     if (marflg[5] && z == 99 && loc != 38)
  76.     speak(155);
  77.     /* the first time they come close */
  78.  
  79.     if (!marflg[5] && loc < 51) {
  80.     marflg[5] = 1;
  81.     speak(142);
  82.     }
  83.     if (loc == 28) {
  84.     if (marflg[3])
  85.         speak(143);
  86.     } else if (loc >= 43 && loc <= 45) {
  87.     if (marflg[4])
  88.         speak(144);
  89.     }
  90.     /* at home */
  91.  
  92.     else if (loc == 42 || loc == 30) {
  93.     if (marflg[0]) {
  94.         if (!marflg[6] || pct(20)) {
  95.         speak(145);
  96.         marflg[6] = 1;
  97.         } else
  98.         speak(146);
  99.     }
  100.     }
  101.     /* the hockey game  */
  102.  
  103.     else if (loc == 29 || (loc >= 31 && loc <= 38)) {
  104.     if (marflg[1]) {
  105.         if (!marflg[7] || pct(20)) {
  106.         speak(147);
  107.         marflg[7] = 1;
  108.         } else
  109.         speak(148);
  110.     }
  111.     } else if (loc == 40) {
  112.     if (marflg[2])
  113.         speak(149);
  114.     } else;
  115.     if (((loc == 42 && marflg[0]) || (loc == 38)) && !deadf) {
  116.     /* oops! he ran inot one and got fried  */
  117.  
  118.     if (loc == 42)
  119.         speak(150);
  120.     if (loc == 38) {
  121.         if (marflg[1])
  122.         speak(151);
  123.         else
  124.         speak(171);
  125.         for (i = 32; i <= 37; i++)
  126.         locdat[i] |= 16384;
  127.     }
  128.     vdead();
  129.     oldlc2 = 0;
  130.     oldloc = 0;
  131.     }
  132.     /* move his belongings to the dump */
  133.  
  134. lab60:
  135.     for (i = 1; i <= MOVMAX; i++) {
  136.     if (obloc[i] == loc || (obloc[i] == 48 && loc == 49) || obloc[i] < 27 ||
  137.         obloc[i] > 50)
  138.         continue;
  139.     if (i == ZWIRE) {
  140.         if (obloc[i] == 1000 || wirelc[0] == 1000 || wirelc[5]
  141.         == 1000 || wirelc[0] == loc || wirelc[1] == loc
  142.         || wirelc[2] == loc || wirelc[3] == loc
  143.         || wirelc[4] == loc || wirelc[5] == loc)
  144.         continue;
  145.         obimpr[ZWIRE] = (obimpr[ZWIRE] & ~56) + 8;
  146.         /* ~56=177707 octal */
  147.  
  148.         for (kkwr = 0; kkwr < 6; kkwr++)
  149.         wirelc[kkwr] = 0;
  150.     }
  151.     if (obloc[i] >= 27 && obloc[i] <= 50)
  152.         obloc[i] = 40;
  153.     if (i == HPUCK)
  154.         obloc[i] = 38;
  155.     if (i == ZDIAMO) {
  156.         obimpr[i] = (obimpr[i] & ~56) + 8;
  157.         obloc[i] = 49;
  158.     }
  159.     if (i == RBOULD)
  160.         obloc[i] = 27;
  161.     }
  162.     return;
  163. }
  164.  
  165. wdemon()
  166. {
  167.     int             i, n, i2, vloc;
  168.     /*
  169.      * take care of playing out and taking in the wire take it in  
  170.      */
  171.  
  172.     if (wirelc[5] == 1000) {
  173.     for (i = 1; i <= 4; i++) {
  174.         n = 5 - i;
  175.         if (wirelc[n] == oldloc && wirelc[n - 1] == loc) {
  176.         wirelc[n] = 1000;
  177.         speak(216);
  178.         if (wirelc[1] == 1000 && obloc[ZWIRE] == 1000 && wirelc[0] == loc) {
  179.             for (i2 = 0; i2 < 5; i2++)
  180.             wirelc[i2] = 0;
  181.             speak(219);
  182.         }
  183.         return;
  184.         }
  185.     }
  186.     if (wirelc[1] == 1000 && wirelc[0] == oldloc && obloc[ZWIRE]
  187.         == loc) {
  188.         wirelc[0] = 1000;
  189.         speak(216);
  190.         return;
  191.     }
  192.     /* play it out  */
  193.  
  194.     if (loc >= 32 && loc <= 38) {
  195.         speak(257);
  196.         if (oldloc == 31 || oldloc == 32)
  197.         vloc = 32;
  198.         else
  199.         vloc = 37;
  200.         for (i = 0; i < 6; i++)
  201.         if (wirelc[i] == 1000)
  202.             wirelc[i] = vloc;
  203.         return;
  204.     }
  205.     for (i = 0; i < 4; i++) {
  206.         if (wirelc[i] == oldloc && wirelc[i + 1] == 1000) {
  207.         wirelc[i + 1] = loc;
  208.         speak(217);
  209.         return;
  210.         }
  211.     }
  212.     if (wirelc[0] == 1000 && obloc[ZWIRE] == oldloc) {
  213.         wirelc[0] = loc;
  214.         speak(217);
  215.         return;
  216.     }
  217.     /* out of wire   */
  218.  
  219.     if (wirelc[4] == oldloc) {
  220.         speak(218);
  221.         wirelc[5] = wirelc[4];
  222.         return;
  223.     }
  224.     } else;
  225. }
  226.  
  227.  
  228. timer(xloc)
  229.     int             xloc;
  230. {
  231.     int             bplce, cplce, gplce, iplce, objen, qq, i;
  232.  
  233.     /* prevent him from being outside the valley at sunset */
  234.  
  235.     if (loc <= 3 && loc * 15 < turns) {
  236.     speak(255);
  237.     oldlc2 = oldloc;
  238.     oldloc = loc;
  239.     loc += 1;
  240.     }
  241.     /*
  242.      * daytim=1 if it is intrinsically light here (i.e. lights are always on
  243.      * or it is outside and the sun is up or he is carrying sphere or bead  
  244.      */
  245.  
  246.     if ((locdat[loc] & 17) != 0 || ((locdat[loc] & 8) != 0
  247.                  && (turns % 100) < 75) || obloc[GSPHER] == 1000
  248.     || obloc[GSPHER] == loc || obloc[ZBEAD] == 1000 ||
  249.     obloc[ZBEAD] == loc)
  250.     daytim = 1;
  251.     else
  252.     daytim = 0;
  253.     /* he is killed if on tower in daytime  */
  254.  
  255.     if (loc == 49 && daytim == 1 && !deadf) {
  256.     speak(166);
  257.     oldlc2 = 0;
  258.     oldloc = 0;
  259.     loc = 48;
  260.     vdead();
  261.     }
  262.     /* announce rising and setting of both suns  */
  263.  
  264.     if ((locdat[loc] & 8) != 0) {
  265.     if (daytim == 0)
  266.         speak(124);
  267.     else if ((turns % 100) >= 72 && (turns % 100) < 75)
  268.         speak(125);
  269.     else if ((turns % 100) < 3 && turns > 4)
  270.         speak(126);
  271.     else;
  272.     }
  273.     /*
  274.      * check to see if he is not wearing shoes or boots if too long without
  275.      * them, he dies  
  276.      */
  277.  
  278.     if ((obloc[CSHOES] != 3000 && obloc[HBOOTS] != 3000) &&
  279.     !deadf && (loc != 16 && loc < 153)) {
  280.     noshoe -= 1;
  281.     if (noshoe == 0)
  282.         speak(99);
  283.     else if (noshoe < -6 && pct(10 * (-6 - noshoe))) {
  284.         speak(100);
  285.         vdead();
  286.     }
  287.     }
  288.     /* fish need water to live!  */
  289.  
  290.     if (obloc[DFISH] == 0) {
  291.     if (obloc[CFISH] != 16 && !(obloc[CFISH] == (2000 + PLBAG)
  292.                     && (((obimpr[PLBAG] / 512) % 8) == 5))) {
  293.         fshlif -= 1;
  294.         if (fshlif == 0) {
  295.         obloc[DFISH] = obloc[CFISH];
  296.         obloc[CFISH] = 0;
  297.         obimpr[CFISH] = 0;
  298.         obimpr[DFISH] = 137;
  299.         }
  300.     }
  301.     }
  302.     /* check on status of bug repellent  */
  303.  
  304.     if (obimpr[ZDEET] >= 4096)
  305.     obimpr[ZDEET] -= 4096;
  306.     /* check on radioactive exposure of film in camera  */
  307.  
  308.     itsher(ZBEAD, &bplce);
  309.     itsher(GSPHER, &gplce);
  310.     if (oextim < 8000) {
  311.     itsher(ICAMER, &iplce);
  312.     if (obloc[GSPHER] == obloc[ICAMER])
  313.         oextim += 1;
  314.     else {
  315.         if (iplce != 0 && gplce != 0)
  316.         oextim += 1;
  317.     }
  318.     if (obloc[ZBEAD] == obloc[ICAMER])
  319.         oextim += 7;
  320.     else {
  321.         if (iplce != 0 && bplce != 0)
  322.         oextim += 4;
  323.     }
  324.     }
  325.     /* check on radiation poisoning  */
  326.  
  327.     if (!deadf && bplce != 0 && obloc[ZBEAD] != 2000 + ZSINK) {
  328.     rdietm = (rdietm / 5) * 5;
  329.     rdietm += 5;
  330.     if (rdietm > 0 && (rdietm % 10) == 0)
  331.         speak(rdietm / 10 + 320);
  332.     } else {
  333.     rdietm -= 1;
  334.     if (rdietm <= 0)
  335.         rdietm = 0;
  336.     if (rdietm == 36)
  337.         speak(326);
  338.     if (rdietm == 24)
  339.         speak(327);
  340.     if (rdietm == 12)
  341.         speak(328);
  342.     }
  343.     /* check on changing of loc 89 */
  344.  
  345.     if (easttm == 1)
  346.     speak(376);
  347.     if (easttm == 15)
  348.     speak(377);
  349.     if (easttm == 50)
  350.     speak(378);
  351.     if (easttm >= 1 && easttm <= 50)
  352.     easttm += 1;
  353.     if (!deadf)
  354.     eattim += 1;
  355.     if (eattim == 170)
  356.     speak(367);
  357.     if (eattim == 240)
  358.     speak(368);
  359.     if (eattim == 270)
  360.     speak(369);
  361.     if (eattim == 300) {
  362.     speak(384);
  363.     vdead();
  364.     }
  365.     /* exposing the x-ray film  */
  366.  
  367.     itsher(ZCASSE, &cplce);
  368.     if (obloc[ZCASSE] == 2000 + ZRACK && obloc[ZBEAD] == 2000 + ZTRAY) {
  369.     objen = 0;
  370.     for (i = 0; i <= MOVMAX; i++) {
  371.         if (obloc[i] == ZENLAR + 2000) {
  372.         if (fimage != 0 && fimage != i)
  373.             filmst = 1;
  374.         qq = i;
  375.         objen += 1;
  376.         }
  377.     }
  378.     if (objen > 1)
  379.         filmst = 1;
  380.     if (objen == 0)
  381.         filmtm += 10;
  382.     if (objen >= 1) {
  383.         filmtm += 1;
  384.         fimage = qq;
  385.     }
  386.     } else if (obloc[ZBEAD] == obloc[ZCASSE] || (obloc[ZBEAD] != ZSINK
  387.                     + 2000 && bplce != 0 && cplce != 0))
  388.     filmtm += 1000;
  389.     else;
  390.     if (filmtm > 3000)
  391.     filmtm = 3000;
  392.     /*
  393.      * dispersing of the cloud from the seed we are using obimpr(zseed) as a
  394.      * clock; this is ok since it no longer exists (  o.e. obloc(zseed)=0 )
  395.      * despite this being stupid  
  396.      */
  397.  
  398.     if (obloc[ZSEED] == 0 && obimpr[ZSEED] > 0) {
  399.     if ((loc == 99 || loc == 131) && obimpr[ZSEED] == 1)
  400.         speak(406);
  401.     obimpr[ZSEED] -= 1;
  402.     }
  403.     if (screef > 0)
  404.     screef -= 1;
  405.     /* the chase is on!!!!    */
  406.  
  407.     if (chaset != 0) {
  408.     if (adverb == QUICKL)
  409.         chaser += 1;
  410.     if (chaset <= 8) {
  411.         if (xloc == loc || loc == oldlc2 || loc == 174 || loc == 166) {
  412.         if (chaset != 1) {
  413.             speak(557);
  414.             vdead();
  415.         } else
  416.             speak(554);
  417.         } else if (chaset >= 5 && chaser < 3)
  418.         speak(556);
  419.         else
  420.         speak(555);
  421.     } else if (chaset == 9) {
  422.         if (chaser >= 3) {
  423.         speak(558);
  424.         guardl = loc;
  425.         } else {
  426.         speak(557);
  427.         vdead();
  428.         }
  429.     } else if ((chaset > 9 && chaset < 18) && loc == guardl) {
  430.         speak(563);
  431.         vdead();
  432.     } else if (loc < 176 && chaset == 18) {
  433.         if (!(loc == 175 && (obimpr[BDOOR] & 2) != 0)) {
  434.         speak(560);
  435.         vdead();
  436.         }
  437.     }
  438.     chaset += 1;
  439.     if (chaset == 19)
  440.         chaset = 0;
  441.     }
  442. }
  443.